using System.Collections.Generic;
using BCW.Friends;
using UnityEngine;

public class ChatWindow : BaseWindow
{
	public enum IdChatType
	{
		general = 0,
		myTeam = 1
	}

	public static ChatWindow instance;

	private IdChatType _idChat;

	public GameObject anchorLeft;

	public GameObject anchorCenter;

	public GameObject anchorFriendCenter;

	public GameObject chatMode;

	public List<SelectableButton> defaultButtons = new List<SelectableButton>();

	public SelectableButtonController chatButtonController;

	public SelectableButtonController messageFilterbuttonController;

	public UILabel poleVvoda;

	public FriendsUIChat TabChat;

	public ChatInGameUIMessageScroll chatRoom;

	public UIGrid messagesGrid;

	public ChatMessage chatMessagePrefab;

	public List<ChatMessage> chatMessageList;

	private int count;

	public IdChatType IdChat
	{
		get
		{
			return _idChat;
		}
		set
		{
			_idChat = value;
		}
	}

	private void Awake()
	{
		instance = this;
	}

	private void OnDestroy()
	{
		instance = null;
		ChatInGameMessageStorage.ClearAllList();
		RefreshEndGame();
	}

	private void OnEnable()
	{
		if ((bool)messageFilterbuttonController)
		{
			messageFilterbuttonController.gameObject.SetActive(TDMController.isTeamGameType);
		}
	}

	private void OnDisable()
	{
	}

	public void RefreshEndGame()
	{
		if ((bool)FriendsController.instance)
		{
			FriendsController.instance.IdsFrinedsInviteToBattle.Clear();
		}
	}

	public override void OnPreShow(object userData)
	{
	}

	public override void OnShow(object userData)
	{
		anchorLeft.SetActive(true);
		chatMode.SetActive(true);
		foreach (SelectableButton defaultButton in defaultButtons)
		{
			defaultButton.Select(true);
		}
		FriendsController.instance.UpdatePlayersDB(null);
	}

	public override void OnHide()
	{
		anchorLeft.SetActive(false);
		chatMode.SetActive(false);
		if ((bool)chatButtonController && (bool)chatButtonController.selectedButton)
		{
			chatButtonController.selectedButton.Select(false);
		}
		if ((bool)messageFilterbuttonController && (bool)messageFilterbuttonController.selectedButton)
		{
			messageFilterbuttonController.selectedButton.Select(false);
		}
	}

	public void ShowKeyboard()
	{
	}

	public void ClearMessageList()
	{
		for (int i = 0; i < chatMessageList.Count; i++)
		{
			Object.Destroy(chatMessageList[i].gameObject);
		}
		chatMessageList.Clear();
	}
}
